﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AtomSite.Domain;
using System.Collections;

namespace AtomSite.WebCore
{
  public class AdminUsersModel : AdminModel
  {
    public AdminUsersModel()
    {
      AddLinks = new Dictionary<string, string>();
    }

    public string Title { get; set; }
    public IPagedList<User> Users { get; set; }
    public IDictionary<string, string> AddLinks { get; set; }
    public bool CanRemove { get; set; }
    public Func<User, string> GetRemoveHref { get; set; }
    public bool CanEdit { get; set; }

    public string GetRoles(User u)
    {
      var roles = new List<string>();
      if (AuthorizeService.IsInRole(u, Scope, AuthRoles.Administrator))
      {
        roles.Add("Admin");
      }
      if (AuthorizeService.IsInRole(u, Scope, AuthRoles.Author))
      {
        roles.Add("Author");
      }
      if (AuthorizeService.IsInRole(u, Scope, AuthRoles.Contributor))
      {
        roles.Add("Contributor");
      }
      return string.Join(", ", roles.ToArray());
    }
  }
}
